package com.xuecheng.media.interfaces.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-08-18  14:30
 */
@Api(tags = "测试接口")
@RestController
@RequestMapping("/test")
public class TestApi {

    @Autowired
    private JavaMailSender mailSender;

    @ApiOperation("发送邮件测试")
    @GetMapping("/t1")
    public void test(){
        SimpleMailMessage message = new SimpleMailMessage();
        // 配置发送者邮箱
        message.setFrom("2770063826@qq.com");
        // 配置接受者邮箱
        message.setTo("2770063826@qq.com");
        // 配置邮件主题
        message.setSubject("主题：简单邮件");
        // 配置邮件内容
        message.setText("测试邮件内容");
        // 发送邮件
        mailSender.send(message);
    }
}
